package org.deri.vor.mobilesensing;

import org.deri.vor.R;
import org.deri.vor.map.GalwayMap;
import org.deri.vor.map.SensorOverLay;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class MobileSensingMap extends MapActivity {
	/** Called when the activity is first created. */
	private GalwayMap map;
	private MapController mController;
	String Check;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.galwaymap);

		Bundle bundle = getIntent().getExtras();

		if (bundle != null) {
			Check = Check + bundle.getString("check");
		}

		
		// Map Set up
		map = (GalwayMap) findViewById(R.id.GalwayMapview);
		map.setBuiltInZoomControls(true);
		mController = map.getController();
		mController.setZoom(15);
		mController.setCenter(new GeoPoint(53289551, -9073712));
		map.Check = Check;
		share_button();
		 SensorOverLay.setAct(MobileSensingMap.this);
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

	
	
	private void share_button(){
		Button button = (Button) findViewById(R.id.btnBack);
		button.setOnClickListener(ms_layout);

		// About Button OnClick
		button = (Button) findViewById(R.id.btnAbout);
		button.setOnClickListener(ms_layout);

		// Home Button OnClick
		button = (Button) findViewById(R.id.btnHome);
		button.setOnClickListener(ms_layout);
		
//		ImageView im  = (ImageView) findViewById(R.id.vor_icon);
//		im.setClickable(true);
//		im.setOnClickListener(ms_layout);
//
//		im = (ImageView) findViewById(R.id.nuig_icon);
//		im.setClickable(true);
//		im.setOnClickListener(ms_layout);
//
//		im = (ImageView) findViewById(R.id.deri_icon);
//		im.setClickable(true);
//		im.setOnClickListener(ms_layout);
	}
    
    
    private OnClickListener ms_layout	=	new OnClickListener(){

		@Override
		public void onClick(View v) {
			switch (v.getId()){
			case R.id.btnAbout  : { jump(72); break;}
			case R.id.btnHome 	: { jump(2); break;}
			case R.id.btnBack  	: { goback(); break;}
//			case R.id.vor_icon  : { jump(3); break;}
//			case R.id.deri_icon : { jump(19); break;}
//			case R.id.nuig_icon : { jump(40); break;}
			}
		}
    };

    private void jump(int page){
    	Intent i = new Intent();
    	i.putExtra("cl",page);
    	i.setClassName("org.deri.vor", "org.deri.vor.VovolOceanRaceActivity");
		startActivity(i);
		finish();
    }
    
    private void goback(){
    	Intent i = new Intent();
    	i.setClassName("org.deri.vor", "org.deri.vor.mobilesensing.MobileSensing");
		finish();
		startActivity(i);
    }
}